package cn.openea.perpartner.crm.config;


import cn.openea.perpartner.common.auth.config.AuthConfig;
import cn.openea.perpartner.common.auth.filter.AppFilter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CrmFilterConfig {
    @Value("${sso.url}")
    private String ssoserver;
    @Value("${sso.logout.path}")
    private String ssologoutpath;
    @Value("${sso.excluded.paths}")
    private String ssoexcludedpaths;
    @Bean
    public FilterRegistrationBean<AppFilter> filterRegistration() {
        FilterRegistrationBean<AppFilter> registration = new FilterRegistrationBean<>();
        registration.setOrder(1);
        registration.addUrlPatterns("/*");
        registration.setFilter(new AppFilter());
        registration.addInitParameter(AuthConfig.SSO_SERVER, ssoserver);
        registration.addInitParameter(AuthConfig.SSO_LOGOUT_PATH, ssologoutpath);
        registration.addInitParameter(AuthConfig.SSO_EXCLUDED_PATHS, ssoexcludedpaths);
        return registration;
    }

}
